package br.org.blacklist.web.componentes;

import org.apache.wicket.Component;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.feedback.FeedbackMessage;
import org.apache.wicket.feedback.IFeedbackMessageFilter;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.model.Model;

public class BlacklistFeedbackPanel extends FeedbackPanel {

    private static final long serialVersionUID = 1L;

    public BlacklistFeedbackPanel(final String id) {
        super(id);
    }

    public BlacklistFeedbackPanel(final String id, final IFeedbackMessageFilter filter) {
        super(id, filter);
    }

    @Override
    protected Component newMessageDisplayComponent(String id, FeedbackMessage message) {
        final Component component = super.newMessageDisplayComponent(id, message);
        String level = new String();
        if (message.getLevel() == FeedbackMessage.INFO) {
            level = "formee-msg-info";
        } else if (message.getLevel() == FeedbackMessage.SUCCESS) {
            level = "formee-msg-success";
        } else if (message.getLevel() == FeedbackMessage.WARNING) {
            level = "formee-msg-warning";
        } else {
            level = "formee-msg-error";
        }
        component.add(new AttributeAppender("class", new Model<String>(level), " "));
        return component;
    }

}
